#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:

    vector<string> arr;
    bool index[20];

    void Dfs(string s, int n, size_t num, string& str)
    {
        if (n == num)
        {
            arr.push_back(s);
            return;
        }
        for (int i = 0;i < str.size();i++)
        {
            if (index[i] == false)
            {
                s.push_back(str[i]);
                index[i] = true;
                Dfs(s, n + 1, num, str);
                s.pop_back();
                index[i] = false;
            }
        }
    }
    vector<string> Permutation(string str) {
        string copy;
        Dfs(copy, 0, str.size(), str);
        return arr;
    }
};

int main()
{
    string s = "ab";
    Solution S;
    S.Permutation(s);
    return 0;
}